def insert_sorted(li):
    for i in range(1, len((li))):
        tmp = li[i]
        j = i - 1  # 手里的牌的位置
        while j >= 0 and li[j] > tmp:
            li[j + 1] = li[j]
            j -= 1
        li[j + 1] = tmp


if __name__ == '__main__':
    l = [5, 7, 6, 3, 1, 2, 9, 8]
    insert_sorted(l)
    print(l)
